package team.seekers.hula.island.islandUser.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.island.island.service.IslandService;
import team.seekers.hula.island.islandUser.entity.dto.IslandEvaluationReqListDTO;
import team.seekers.hula.island.islandUser.entity.dto.IslandUserBindDTO;
import team.seekers.hula.island.islandUser.entity.dto.IslandUserPageDTO;
import team.seekers.hula.island.islandUser.entity.vo.IslandEvaluationListVO;
import team.seekers.hula.island.islandUser.entity.vo.IslandUserListVO;
import team.seekers.hula.island.islandUser.service.IslandUserService;


@Controller
@ApiResponseBody
@RequestMapping("/island/user")
@Slf4j
public class IslandUserController {

    @Autowired
    private IslandService islandService;

    @Autowired
    private IslandUserService islandUserService;

    @GetMapping("/page")
    public PageResult<IslandUserListVO> list(IslandUserPageDTO pageDTO) {
        return islandUserService.pageUser(pageDTO);
    }

    @GetMapping("/evaluation/page")
    public PageResult<IslandEvaluationListVO> listEvaluation(IslandEvaluationReqListDTO listDTO) {
        return islandService.pageEvaluation(listDTO);
    }

    @GetMapping("/collectOrCancel")
    public void collectOrCancel(@RequestParam String islandId) {
//        islandService.collectOrCancel(courseId, MindUtils.getUserId());
    }

    @GetMapping("/fixedOrCancel")
    public void fixedOrCancel(@RequestParam String islandId) {
        islandUserService.fixedOrCancel(islandId, MindUtils.getUserId());
    }

    /**
     * 浪屿用户绑定
     */
    @PostMapping("/join")
    public void join(@RequestBody IslandUserBindDTO islandUserBindDTO){
        islandUserBindDTO.setUserId(MindUtils.getUserId());
        islandUserService.bind(islandUserBindDTO);
    }

}
